import  {defineStore} from 'pinia'
import { ref } from 'vue'
import axios from 'axios'

// 定义store 
// defineStore(仓库唯一标识)
export const useChannelStore = defineStore('channel', () => {
    // 声明数据
    const channelList = ref([])

    // 声明操作数据的方法
    const getList = async() => {
        // 支持异步
        const {data: {data}} = await axios.get('http://geek.itheima.net/v1_0/channels')

        channelList.value = data.channels

        console.log(data.channels)
    }

    // 声明getters相关



    return {
        channelList,
        getList
    }
},{
  //  persist:true // 开启当前模块的持久化
  persist: {
    key: 'hm-counter', // 修改本地存储的唯一标识
    paths: ['count'] // 存储的是哪些数据
  }
})